indexgoodsObj={
	showAll:function(){
		$('#indexgoodsDatagrid').datagrid({
				queryParams:''
		});
		$('.datagrid-pager-form').find('.datagrid-pager').css({'position':'relative','bottom':'0'});
	},
	save:function(url){
		$('#passwordsetForm').form('submit',{
            url: url,
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
				var result=eval('('+result+')');
            	$.messager.confirm('提示',result.message,function(r){
                    	$('#passwordsetDialog').dialog('close');
                });
            }
        });
	},
	passwordsetBar:function(){
		$('#passwordsetDialog').dialog('open');
		$('#passwordset_username').textbox('setValue',username);
		$('#passwordset_nick_name').textbox('setValue',nick_name);
	},
	addBar:function(status,url){
		// if(status=='moveDepotInfo'){
			// var addgoodsUrl="/Stock/moveDepotInfoaddgoods";//添加商品
		// }
		// if(status=='otherOutboundInfo'){
			// var addgoodsUrl="/Stock/otherOutboundInfoaddgoods";//添加商品
		// }
		var addgoodsUrl=url;
		// alert(addgoodsUrl);
		var indexgoodsRow=$('#indexgoodsDatagrid').datagrid('getSelections');
        if (indexgoodsRow.length>0){
        	$.messager.confirm('提示','真的要添加这'+indexgoodsRow.length+'个商品吗?',function(r){
                if (r){
                	var ids=[];
                	for(var i=0;i<indexgoodsRow.length;i++){
                		ids.push(indexgoodsRow[i].id);
                	}
                	var id=ids.join(',');
					// addgoodsUrl="http://"+window.location.host+addgoodsUrl;
					// alert(addgoodsUrl);
					// return false;
                    $.post(addgoodsUrl,{id:id,order_id:order_id},function(result){
                        if (result.status){
							$.messager.alert('提示信息',result.message,'info',function(r){
								$('#indexgoodsAddDialog').dialog('close');
								if(status=='moveDepotInfo'){
									$('#moveDepotInfoDatagrid').datagrid('reload'); 
								}
								if(status=='otherOutboundInfo'){
									$('#otherOutboundInfoDatagrid').datagrid('reload'); 
								}
								
							});
                        }else{
                            $.messager.alert('错误提示',result.message,'error');
                        }
                    },'json').error(function(data){
                    	var info=eval('('+data.responseText+')');
						$.messager.confirm('错误提示',info.message,function(r){
							//$('#authAccessSetDialog').dialog('close');
						});
                    });	
                }
        	});
		}else{
			$.messager.alert('推送提示','请选择列表数据','error');
		}
	},
	addinfoBar:function(status,url){
		 $('#indexgoodsAddDialog').dialog({
			// minimizable: true,//最小化，默认false  
	//         maximizable: true, //最大化，默认false  
	//         collapsible: true, //可折叠，默认false
			//按钮  
            buttons: [{
                text: '确定添加',
                iconCls: 'icon-ok',
                handler: function () {
					indexgoodsObj.addBar(status,url);
                }
            }, {
                text: '取消',
                handler: function () {
                    $('#indexgoodsAddDialog').dialog('close');
                }
            }]
		});
        $('#indexgoodsAddDialog').dialog('open').dialog('setTitle','商品列表');
		
		$('#indexgoodsDatagrid').datagrid({
			url:getgoodsUrl,
			fitColumns:true,
			rownumbers:true,
			pageSize:25,
			pageNumber:1,
			pageList:[1,2,5,10,15,20,25,30,40,50],
			columns:[[
			{field:'id',title:'id',checkbox:true},
			{field:'goods_no',title:'商品编码',sortable:true},
			{field:'manual_id',title:'账册编码',sortable:true},
			{field:'goods_name',title:'商品名称',sortable:true},
			{field:'bar_code',title:'条形码',sortable:true},
			{field:'goods_spec',title:'规格',sortable:true},
			{field:'storage_amount',title:'库存数量',sortable:true},
			{field:'order_no',title:'单号',sortable:true},
			{field:'batch_no',title:'批次号',sortable:true}
			]],
			onLoadError:function(data){
				var info=eval('('+data.responseText+')');
				$.messager.confirm('错误提示',info.message,function(r){
					var tab=$('#Tabs').tabs('getSelected');
					var index=$('#Tabs').tabs('getTabIndex',tab);
					$('#Tabs').tabs('close',index);
				});
			},
			pagination:true,
			fit:true,
		});
		$('.datagrid-pager-form').find('.datagrid-pager').css({'position':'relative','bottom':'0'});
	}
};